﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;

using System.Text;
using System.Windows.Forms;
using System.Threading;

namespace QUANLYCHAMCONG.PL.CMS
{
    public partial class Content : UserControl
    {
        #region "Event"
        public delegate void _DanhsachClick();
        public event _DanhsachClick DanhsachNhanvien;
        public delegate void _Lichsunhanvien();
        public event _Lichsunhanvien Lichsunhanvien;
        public delegate void _Chamcongnhanvien();
        public event _Chamcongnhanvien Chamcongnhanvien;
        public delegate void _Hopdongnhanvien();
        public event _Hopdongnhanvien Hopdongnhanvien;
        public delegate void _Dangkymaychamcong();
        public event _Dangkymaychamcong Dangkymaychamcong;
        public delegate void _Ketnoimaychamcong();
        public event _Ketnoimaychamcong Ketnoimaychamcong;
        public delegate void _Saoluudulieumaychamcong();
        public event _Saoluudulieumaychamcong Saoluudulieumaychamcong;

        public delegate void _Dangkytangca();
        public event _Dangkytangca Dangkytangca;
        public delegate void _Dangkyditrevesom();
        public event _Dangkyditrevesom Dangkyditrevesom;
        public delegate void _Dangkydicongtac();
        public event _Dangkydicongtac Dangkydicongtac;
        public delegate void _Taotaikhoan();
        public event _Taotaikhoan Taotaikhoan;
        public delegate void _PhanquyenTaikhoan();
        public event _PhanquyenTaikhoan PhanquyenTaikhoan;
        public delegate void _Cauhinhhethong();
        public event _Cauhinhhethong Cauhinhhethong;
        public delegate void _Thaydoipass();
        public event _Thaydoipass Thaydoipass;
        public delegate void _BackupDulieu();
        public event _BackupDulieu BackupDulieu;
        public delegate void _Thamsohethong();
        public event _Thamsohethong Thamsohethong;
        public delegate void _Ngayle();
        public event _Ngayle Ngayle;
        public delegate void _Ca();
        public event _Ca Ca;
        public delegate void _Congty();
        public event _Congty Congty;
        public delegate void _Ngaylamviec();
        public event _Ngaylamviec Ngaylamviec;
        public delegate void _Baocaotinhhinhlamviec();
        public event _Baocaotinhhinhlamviec Baocaotinhhinhlamviec;
        public delegate void _Chamcongchitiet();
        public event _Chamcongchitiet Chamcongchitiet;
        public delegate void _Danhsachnhanvienvang();
        public event _Danhsachnhanvienvang Danhsachnhanvienvang;
        public delegate void _Thongke();
        public event _Thongke Thongke;
        public delegate void _Dangkynghiphep();
        public event _Dangkynghiphep Dangkynghiphep;
        public delegate void _DownloadNhanvien();
        public event _DownloadNhanvien DownloadNhanvien;
        #endregion
        #region "Method"
        public Content()
        {
            InitializeComponent();
        }
        public DataTable Dataactive;
        private void ldanhsachnhanvien_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
        {
            if (this.DanhsachNhanvien != null)
            {
                this.DanhsachNhanvien();
            }
        }
        private void lnkdangkymaychamcong_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
        {
            if (this.Dangkymaychamcong != null)
                this.Dangkymaychamcong();
        }
        private void llichsunhanvien_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
        {
            if (this.Lichsunhanvien != null)
                this.Lichsunhanvien();
        }
        private void lchamcongnhanvien_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
        {
            if (this.Chamcongnhanvien != null)
                this.Chamcongnhanvien();
        }
        private void lhopdongnhanvien_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
        {
            if (this.Hopdongnhanvien != null)
                this.Hopdongnhanvien();
        }
        private void lketnoimaychamcong_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
        {
            if (this.Ketnoimaychamcong != null)
                this.Ketnoimaychamcong();
        }
        private void lsaoluudulieucc_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
        {
            if (this.Saoluudulieumaychamcong != null)
                this.Saoluudulieumaychamcong();
        }
        private void ldangkytangca_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
        {
            if (this.Dangkytangca != null)
                this.Dangkytangca();
        }
        private void ldangkyditrevesom_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
        {
            if (this.Dangkyditrevesom != null)
                this.Dangkyditrevesom();
        }
        private void ldangkynghiphep_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
        {
            if (this.Dangkynghiphep != null)
                this.Dangkynghiphep();
        }
        private void ldangkydicongtac_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
        {
            if (this.Dangkydicongtac != null)
                this.Dangkydicongtac();
        }
        private void ttaotaikhoan_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
        {
            if (this.Taotaikhoan != null)
                this.Taotaikhoan(); 
        }
        private void lphanquyentaikhoan_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
        {
            if (this.PhanquyenTaikhoan != null)
                this.PhanquyenTaikhoan();
        }
        private void lcauhinhhethong_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
        {
            if (this.Cauhinhhethong != null)
                this.Cauhinhhethong();
        }
        private void lthaydoipass_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
        {
            if (this.Thaydoipass != null)
                this.Thaydoipass();
        }
        private void lbackupretore_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
        {
            if (this.BackupDulieu != null)
                this.BackupDulieu();
        }
        private void lbthamsohethong_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
        {
            if (this.Thamsohethong != null)
                this.Thamsohethong();
        }
        private void lngayle_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
        {
            if (this.Ngayle != null)
                this.Ngayle();
        }
        private void lcalamviec_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
        {
            if (this.Ca != null)
                this.Ca();
        }
        private void lcongty_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
        {
            if (this.Congty != null)
                this.Congty();
        }
        private void lngaylamviec_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
        {
            if (this.Ngaylamviec != null)
                this.Ngaylamviec();
        }
        private void lbaocaotinhhinhlamviec_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
        {
            if (this.Baocaotinhhinhlamviec != null)
                this.Baocaotinhhinhlamviec();
        }
        private void lchamcongchitiet_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
        {
            if (this.Chamcongchitiet != null)
                this.Chamcongchitiet();
        }
        private void lbaocaonhanvienvang_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
        {
            if (this.Danhsachnhanvienvang != null)
                this.Danhsachnhanvienvang();
        }
        private void lthongke_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
        {
            if (this.Thongke != null)
            {
                this.Thongke();
            }
        }
        public void SetActiveLink(bool danhsachnhanvien, bool dangkymaychamcong, bool lichsunhanvien, bool chamcongnhanvien,
            bool hopdongnhanvien, bool ketnoimaychamcong, bool saoluudulieu, bool tangca, bool ditre, bool nghiphep, bool dicongtac,
            bool taotaikhoan, bool phanquyentaikhoan, bool cauhinhhethong, bool thaydoipass, bool backup, bool thamsohethong, bool ngayle,
            bool ca, bool congty, bool ngaylamviec, bool baocaotinhhinhlamviec, bool chamcongchitiet, bool nhanvienvang, bool thongke)
        {
            if (danhsachnhanvien)
                ldanhsachnhanvien.Enabled = true;
            else
                ldanhsachnhanvien.Enabled = false;
            if (dangkymaychamcong)
                lnkdangkymaychamcong.Enabled = true;
            else
                lnkdangkymaychamcong.Enabled = false;
            if (lichsunhanvien)
                llichsunhanvien.Enabled = true;
            else
                llichsunhanvien.Enabled = false;
            if (chamcongnhanvien)
                lchamcongnhanvien.Enabled = true;
            else
                lchamcongnhanvien.Enabled = false;
            if (hopdongnhanvien)
                lhopdongnhanvien.Enabled = true;
            else
                lhopdongnhanvien.Enabled = false;
            if (ketnoimaychamcong)
                lketnoimaychamcong.Enabled = true;
            else
                lketnoimaychamcong.Enabled = false;
            if (saoluudulieu)
                lsaoluudulieucc.Enabled = true;
            else
                lsaoluudulieucc.Enabled = false;
            if (tangca)
                ldangkytangca.Enabled = true;
            else
                ldangkytangca.Enabled = false;
            if (ditre)
                ldangkyditrevesom.Enabled = true;
            else
                ldangkyditrevesom.Enabled = false;
            if (nghiphep)
                ldangkynghiphep.Enabled = true;
            else
                ldangkynghiphep.Enabled = false;
            if (dicongtac)
                ldangkydicongtac.Enabled = true;
            else
                ldangkydicongtac.Enabled = false;
            if(taotaikhoan)
                ttaotaikhoan.Enabled=true;
            else
                ttaotaikhoan.Enabled=false;
            if(phanquyentaikhoan)
                lphanquyentaikhoan.Enabled=true;
            else
                lphanquyentaikhoan.Enabled=false;
            if(cauhinhhethong)
                lcauhinhhethong.Enabled=true;
            else
                lcauhinhhethong.Enabled=false;
            if(thaydoipass)
                lthaydoipass.Enabled=true;
            else
                lthaydoipass.Enabled=false;
            if(backup)
                lbackupretore.Enabled=true;
            else
                lbackupretore.Enabled=false;
            if(thamsohethong)
                lbthamsohethong.Enabled=true;
            else
                lbthamsohethong.Enabled=false;
            if(ngayle)
                lngayle.Enabled=true;
            else
                lngayle.Enabled=false;
            if(ca)
                lcalamviec.Enabled=true;
            else
                lcalamviec.Enabled=false;
            if(congty)
                lcongty.Enabled=true;
            else
                lcongty.Enabled=false;
            if(ngaylamviec)
                lngaylamviec.Enabled=true;
            else
                lngaylamviec.Enabled=false;
            if(baocaotinhhinhlamviec)
                lbaocaotinhhinhlamviec.Enabled=true;
            else
                lbaocaotinhhinhlamviec.Enabled=false;
            if(chamcongchitiet)
                lchamcongchitiet.Enabled=true;
            else
                lchamcongchitiet.Enabled=false;
            if(nhanvienvang)
                lbaocaonhanvienvang.Enabled=true;
            else
                lbaocaonhanvienvang.Enabled=false;
            if (thongke)
                lthongke.Enabled = true;
            else
                lthongke.Enabled = false;
        }
        #endregion
        public void SetEnableLink()
        {
            if (Dataactive.Rows.Count != 0)
            {
                foreach (DataRow dr in Dataactive.Rows)
                {
                    foreach (Control c in this.Controls)
                    {
                        if (c is Panel)
                        {
                            //check group
                            foreach (Control c1 in c.Controls)
                            {
                                if (c1 is GroupBox)
                                {
                                    foreach (Control c2 in c1.Controls)
                                    {
                                        if (c2 is LinkLabel)
                                        {
                                            if (c2.Name.ToString() == dr["MENUVALUE"].ToString())
                                            {
                                                c2.Visible = true;
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }

        private void llaydulieuchamcong_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
        {
            if (this.DownloadNhanvien != null)
            {
                this.DownloadNhanvien();
            }
        }
    }
       
}
